#ifndef NET_SOCKET_H
#define NET_SOCKET_H

#include "utility/Noncopyable.h"

class Sockaddr;

class Socket final
{
public:
    explicit Socket(int fd): _fd{fd} {}
    /// @brief will colse fd
    ~Socket();

    int fd() const { return _fd; }

    int accept(Sockaddr &peer) const;
    void bind(const Sockaddr &local) const;
    void keep_alive(bool option) const;
    void listen() const;
    void reuse_addr(bool option) const;
    void reuse_port(bool option) const;
    void shutdown_write() const;

private:
    NONCOPYABLE(Socket);

    const int _fd;
};



#endif